import { defineMock } from 'vite-plugin-mock-dev-server'
export default defineMock([
  {
    url: '/api/login',
    method: 'POST',
    status: 200,
    body({ query, params, body, headers }) {
      if (body.loginName === 'admin' && body.password === 'e6e061838856bf47e1de730719fb2609') {
        return {
          status: '200',
          message: 'success',
          result: {
            user: {
              _id: '64210e1e66d2f8e7e9c6396a',
              password: 'e6e061838856bf47e1de730719fb2609',
              userId: '202200001',
              roleId: '',
              userName: '本地mock用户',
              loginName: 'admin'
            },
            menus: [
              {
                _id: '642536db66d2f8e7e9c63af5',
                path: '/dashboard',
                id: '9230129301230000009',
                name: '数据看版',
                component: 'views/dashboard/Home',
                icon: 'monitor',
                order: 1
              },
              {
                _id: '6410357a66d2f8e7e9c6395d',
                path: '/workInfo',
                id: '9230129301230000001',
                name: '项目信息',
                component: 'views/work-info/WorkInfo',
                icon: 'user',
                order: 2
              },
              {
                _id: '642162ec66d2f8e7e9c6396d',
                path: '/docs',
                id: '9230129301230000002',
                name: '使用手册',
                icon: 'user',
                children: [
                  {
                    path: '/docs/comparison',
                    id: '9230129301230000003',
                    name: 'vue3变动',
                    icon: 'user',
                    component: 'views/docs/Composition',
                    order: 1
                  },
                  {
                    path: '/docs/optVsComposition',
                    id: '9230129301230000004',
                    name: 'option API 对比 Composition API',
                    icon: 'umbrella',
                    component: 'views/docs/OptVsComposition',
                    order: 3
                  },
                  {
                    path: '/docs/setup',
                    id: '9230129301230000006',
                    name: 'setup',
                    icon: 'management',
                    component: 'views/docs/Setup',
                    order: 2
                  }
                ],
                order: 3
              },
              {
                _id: '6421631c66d2f8e7e9c6396e',
                path: '/table',
                id: '9230129301230000007',
                name: '表格Demo',
                component: 'views/table/Demo',
                icon: 'officeBuilding',
                order: 4
              },
              {
                _id: '6421634466d2f8e7e9c6396f',
                path: '/hooks',
                id: '9230129301230000008',
                name: 'hooks',
                component: 'views/custom-hooks/Demo',
                icon: 'coldDrink',
                order: 5
              },
              {
                _id: '6439113eafcc56de9608cafb',
                path: '/feat',
                id: '9230129301230000009',
                name: '功能展示',
                component: 'views/dashboard/Home',
                icon: 'reading',
                order: 6,
                children: [
                  {
                    path: '/feat/i18n',
                    id: '9230129301230000003',
                    name: '国际化',
                    icon: 'aim',
                    component: 'views/i18n/I18n',
                    order: '1'
                  }
                ]
              }
            ],
            token:
              'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNjgzNjMyODE1LCJleHAiOjE2ODM2NDAwMTV9.-bsjeZ4QBzaiilaZ0EyZt7s0vBPPAGsJOkGPgVhwV6A'
          },
          success: true
        }
      } else {
        return {
          status: '403',
          message: '当前为mock环境，请使用admin/admin@123进行登录',
          result: {}
        }
      }
    }
  },
  {
    url: '/api/getMenus',
    method: 'POST',
    status: 200,
    body: {
      status: '200',
      message: 'success',
      result: [
        {
          _id: '642536db66d2f8e7e9c63af5',
          path: '/dashboard',
          id: '9230129301230000009',
          name: '数据看版',
          component: 'views/dashboard/Home',
          icon: 'monitor',
          order: 1
        },
        {
          _id: '6410357a66d2f8e7e9c6395d',
          path: '/workInfo',
          id: '9230129301230000001',
          name: '项目信息',
          component: 'views/work-info/WorkInfo',
          icon: 'user',
          order: 2
        },
        {
          _id: '642162ec66d2f8e7e9c6396d',
          path: '/docs',
          id: '9230129301230000002',
          name: '使用手册',
          icon: 'user',
          children: [
            {
              path: '/docs/comparison',
              id: '9230129301230000003',
              name: 'vue3变动',
              icon: 'user',
              component: 'views/docs/Composition',
              order: 1
            },
            {
              path: '/docs/optVsComposition',
              id: '9230129301230000004',
              name: 'option API 对比 Composition API',
              icon: 'umbrella',
              component: 'views/docs/OptVsComposition',
              order: 3
            },
            {
              path: '/docs/setup',
              id: '9230129301230000006',
              name: 'setup',
              icon: 'management',
              component: 'views/docs/Setup',
              order: 2
            }
          ],
          order: 3
        },
        {
          _id: '6421631c66d2f8e7e9c6396e',
          path: '/table',
          id: '9230129301230000007',
          name: '表格Demo',
          component: 'views/table/Demo',
          icon: 'officeBuilding',
          order: 4
        },
        {
          _id: '6421634466d2f8e7e9c6396f',
          path: '/hooks',
          id: '9230129301230000008',
          name: 'hooks',
          component: 'views/custom-hooks/Demo',
          icon: 'coldDrink',
          order: 5
        },
        {
          _id: '6439113eafcc56de9608cafb',
          path: '/feat',
          id: '9230129301230000009',
          name: '功能展示',
          component: 'views/dashboard/Home',
          icon: 'reading',
          order: 6,
          children: [
            {
              path: '/feat/i18n',
              id: '9230129301230000003',
              name: '国际化',
              icon: 'aim',
              component: 'views/i18n/I18n',
              order: '1'
            }
          ]
        }
      ],
      success: true
    }
  }
])
